home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / tcl / tests / scan.test < prev    next >
Text File  |  1992-11-06  |  20KB  |  653 lines

  1. # Commands covered:  scan
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright 1991 Regents of the University of California
  8. # Permission to use, copy, modify, and distribute this
  9. # software and its documentation for any purpose and without
  10. # fee is hereby granted, provided that this copyright notice
  11. # appears in all copies.  The University of California makes no
  12. # representations about the suitability of this software for any
  13. # purpose.  It is provided "as is" without express or implied
  14. # warranty.
  15. #
  16. # $Header: /user6/ouster/tcl/tests/RCS/scan.test,v 1.11 92/04/29 08:55:00 ouster Exp $ (Berkeley)
  17.  
  18. if {[string compare test [info procs test]] == 1} then {source defs}
  19.  
  20. test scan-1.1 {integer scanning} {
  21.     set a {}; set b {}; set c {}; set d {}
  22.     scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  23. } 4
  24. test scan-1.2 {integer scanning} {
  25.     set a {}; set b {}; set c {}; set d {}
  26.     scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  27.     set a
  28. } -20
  29. test scan-1.3 {integer scanning} {
  30.     set a {}; set b {}; set c {}; set d {}
  31.     scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  32.     set b
  33. } 1476
  34. test scan-1.4 {integer scanning} {
  35.     set a {}; set b {}; set c {}; set d {}
  36.     scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  37.     set c
  38. } 33
  39. test scan-1.5 {integer scanning} {
  40.     set a {}; set b {}; set c {}; set d {}
  41.     scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  42.     set d
  43. } 0
  44. test scan-1.6 {integer scanning} {
  45.     set a {}; set b {}; set c {}
  46.     scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  47. } 3
  48. test scan-1.7 {integer scanning} {
  49.     set a {}; set b {}; set c {}
  50.     scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  51.     set a
  52. } -4
  53. test scan-1.8 {integer scanning} {
  54.     set a {}; set b {}; set c {}
  55.     scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  56.     set b
  57. } 16
  58. test scan-1.9 {integer scanning} {
  59.     set a {}; set b {}; set c {}
  60.     scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  61.     set c
  62. } 7890
  63.  
  64. # Capitalized format specifiers don't work on some systems, so
  65. # only run the following tests at Berkeley.
  66.  
  67. if $atBerkeley {
  68.     test scan-1.10 {integer scanning} {
  69.     set a {}; set b {}; set c {}; set d {}
  70.     scan "-45 16 +10 987" "%D %d %D %d" a b c d
  71.     } 4
  72.     test scan-1.11 {integer scanning} {
  73.     set a {}; set b {}; set c {}; set d {}
  74.     scan "-45 16 +10 987" "%D %d %D %d" a b c d
  75.     set a
  76.     } -45
  77.     test scan-1.12 {integer scanning} {
  78.     set a {}; set b {}; set c {}; set d {}
  79.     scan "-45 16 +10 987" "%D %d%D %d" a b c d
  80.     set b
  81.     } 16
  82.     test scan-1.13 {integer scanning} {
  83.     set a {}; set b {}; set c {}; set d {}
  84.     scan "-45 16 +10 987" "%D %d %D %d" a b c d
  85.     set c
  86.     } 10
  87.     test scan-1.14 {integer scanning} {
  88.     set a {}; set b {}; set c {}; set d {}
  89.     scan "-45 16 +10 987" "%D %d %D %d" a b c d
  90.     set d
  91.     } 987
  92.     test scan-1.15 {integer scanning} {
  93.     set a {}; set b {}; set c {}; set d {}
  94.     scan "14 1ab 62 10" "%d %x %O %x" a b c d
  95.     } 4
  96.     test scan-1.16 {integer scanning} {
  97.     set a {}; set b {}; set c {}; set d {}
  98.     scan "14 1ab 62 10" "%d %x %O %x" a b c d
  99.     set a
  100.     } 14
  101.     test scan-1.17 {integer scanning} {
  102.     set a {}; set b {}; set c {}; set d {}
  103.     scan "14 1ab 62 10" "%d %x %O %x" a b c d
  104.     set b
  105.     } 427
  106.     test scan-1.18 {integer scanning} {
  107.     set a {}; set b {}; set c {}; set d {}
  108.     scan "14 1ab 62 10" "%d %x %O %x" a b c d
  109.     set c
  110.     } 50
  111.     test scan-1.19 {integer scanning} {
  112.     set a {}; set b {}; set c {}; set d {}
  113.     scan "14 1ab 62 10" "%d %x %O %x" a b c d
  114.     set d
  115.     } 16
  116.     test scan-1.20 {integer scanning} {
  117.     set a {}; set b {}; set c {}; set d {}
  118.     scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  119.     } 4
  120. }
  121. test scan-1.21 {integer scanning} {
  122.     set a {}; set b {}; set c {}; set d {}
  123.     scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  124.     set a
  125. } 2739128
  126. test scan-1.22 {integer scanning} {
  127.     set a {}; set b {}; set c {}; set d {}
  128.     scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  129.     set b
  130. } 342391
  131. test scan-1.23 {integer scanning} {
  132.     set a {}; set b {}; set c {}; set d {}
  133.     scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  134.     set c
  135. } 561323
  136. test scan-1.24 {integer scanning} {
  137.     set a {}; set b {}; set c {}; set d {}
  138.     scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  139.     set d
  140. } 52719
  141. test scan-1.25 {integer scanning} {
  142.     set a {}; set b {}; set c {}; set d {}
  143.     scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  144. } 4
  145. test scan-1.26 {integer scanning} {
  146.     set a {}; set b {}; set c {}; set d {}
  147.     scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  148.     set a
  149. } 171
  150. test scan-1.27 {integer scanning} {
  151.     set a {}; set b {}; set c {}; set d {}
  152.     scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  153.     set b
  154. } 291
  155. test scan-1.28 {integer scanning} {
  156.     set a {}; set b {}; set c {}; set d {}
  157.     scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  158.     set c
  159. } -20
  160. test scan-1.29 {integer scanning} {
  161.     set a {}; set b {}
  162.     scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  163.     set d
  164. } 52
  165. test scan-1.30 {integer scanning} {
  166.     set a {}; set b {}
  167.     scan "1234567 234 567  " "%*3x %x %*o %4o" a b
  168. } 2
  169. test scan-1.31 {integer scanning} {
  170.     set a {}; set b {}
  171.     scan "1234567 234 567  " "%*3x %x %*o %4o" a b
  172.     set a
  173. } 17767
  174. test scan-1.32 {integer scanning} {
  175.     set a {}; set b {}
  176.     scan "a    1234" "%d %d" a b
  177. } 0
  178. test scan-1.33 {integer scanning} {
  179.     set a {}
  180.     scan "a    1234" "%d %d" a b
  181.     set a
  182. } {}
  183. test scan-1.34 {integer scanning} {
  184.     set a {}; set b {}; set c {}; set d {};
  185.     scan "12345678" "%2d %2d %2d %2d" a b c d
  186. } 4
  187. test scan-1.35 {integer scanning} {
  188.     set a {}; set b {}; set c {}; set d {};
  189.     scan "12345678" "%2d %2d %2d %2d" a b c d
  190.     set a
  191. } 12
  192. test scan-1.36 {integer scanning} {
  193.     set a {}; set b {}; set c {}; set d {}
  194.     scan "12345678" "%2d %2d %2d %2d" a b c d
  195.     set b
  196. } 34
  197. test scan-1.37 {integer scanning} {
  198.     set a {}; set b {}; set c {}; set d {}
  199.     scan "12345678" "%2d %2d %2d %2d" a b c d
  200.     set c
  201. } 56
  202. test scan-1.38 {integer scanning} {
  203.     set a {}; set b {}; set c {}; set d {}
  204.     scan "12345678" "%2d %2d %2d %2d" a b c d
  205.     set d
  206. } 78
  207. test scan-1.39 {integer scanning} {
  208.     set a {}; set b {}; set c {}; set d {}
  209.     scan "1 2 " "%d %d %d %d" a b c d
  210. } 2
  211. test scan-1.40 {integer scanning} {
  212.     set a {}; set b {}; set c {}; set d {}
  213.     scan "1 2 " "%d %d %d %d" a b c d
  214.     set a
  215. } 1
  216. test scan-1.41 {integer scanning} {
  217.     set a {}; set b {}; set c {}; set d {}
  218.     scan "1 2 " "%d %d %d %d" a b c d
  219.     set b
  220. } 2
  221. test scan-1.42 {integer scanning} {
  222.     set a {}; set b {}; set c {}; set d {}
  223.     scan "1 2 " "%d %d %d %d" a b c d
  224. } 2
  225. test scan-1.43 {integer scanning} {
  226.     set a {}; set b {}; set c {}; set d {}
  227.     scan "1 2 " "%d %d %d %d" a b c d
  228.     set d
  229. } {}
  230.  
  231. test scan-2.1 {floating-point scanning} {
  232.     set a {}; set b {}; set c {}; set d {}
  233.     scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  234. } 3
  235. test scan-2.2 {floating-point scanning} {
  236.     set a {}; set b {}; set c {}; set d {}
  237.     scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  238.     set a
  239. } 2.1
  240. test scan-2.3 {floating-point scanning} {
  241.     set a {}; set b {}; set c {}; set d {}
  242.     scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  243.     set b
  244. } -3e+08
  245. test scan-2.4 {floating-point scanning} {
  246.     set a {}; set b {}; set c {}; set d {}
  247.     scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  248.     set c
  249. } 0.99962
  250. test scan-2.5 {floating-point scanning} {
  251.     set a {}; set b {}; set c {}; set d {}
  252.     scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  253.     set d
  254. } {}
  255. test scan-2.6 {floating-point scanning} {
  256.     set a {}; set b {}; set c {}; set d {}
  257.     scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  258. } 4
  259. test scan-2.7 {floating-point scanning} {
  260.     set a {}; set b {}; set c {}; set d {}
  261.     scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  262.     set a
  263. } -1
  264. test scan-2.8 {floating-point scanning} {
  265.     set a {}; set b {}; set c {}; set d {}
  266.     scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  267.     set b
  268. } 234
  269. test scan-2.9 {floating-point scanning} {
  270.     set a {}; set b {}; set c {}; set d {}
  271.     scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  272.     set c
  273. } 5
  274. test scan-2.10 {floating-point scanning} {
  275.     set a {}; set b {}; set c {}; set d {}
  276.     scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  277.     set d
  278. } 8.2
  279. test scan-2.11 {floating-point scanning} {
  280.     set a {}; set b {}; set c {}
  281.     scan "1e00004 332E-4 3e+4" "%f %*2e %f %f" a b c
  282. } 3
  283. test scan-2.12 {floating-point scanning} {
  284.     set a {}; set b {}; set c {}
  285.     scan "1e00004 332E-4 3e+4" "%f %*2e %f %f" a b c
  286.     set a
  287. } 10000
  288. test scan-2.13 {floating-point scanning} {
  289.     set a {}; set b {}; set c {}
  290.     scan "1e00004 332E-4 3e+4" "%f %*2e %f %f" a b c
  291.     set c
  292. } 30000
  293. if $atBerkeley {
  294.     test scan-2.14 {floating-point scanning} {
  295.     set a {}; set b {}; set c {}
  296.     scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  297.     } 3
  298. }
  299. test scan-2.15 {floating-point scanning} {
  300.     set a {}; set b {}; set c {}
  301.     scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  302.     set a
  303. } 1
  304. test scan-2.16 {floating-point scanning} {
  305.     set a {}; set b {}; set c {}
  306.     scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  307.     set b
  308. } 200
  309. if $atBerkeley {
  310.     test scan-2.17 {floating-point scanning} {
  311.     set a {}; set b {}; set c {}
  312.     scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  313.     set c
  314.     } 3
  315.     test scan-2.18 {floating-point scanning} {
  316.     set a {}; set b {}
  317.     scan "1.eabc" "%f %x" a b
  318.     } 2
  319.     test scan-2.19 {floating-point scanning} {
  320.     set a {}; set b {}
  321.     scan "1.eabc" "%f %x" a b
  322.     set a
  323.     } 1
  324. }
  325. test scan-2.20 {floating-point scanning} {
  326.     set a {}; set b {}; set c {}; set d {}
  327.     scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  328. } 4
  329. test scan-2.21 {floating-point scanning} {
  330.     set a {}; set b {}; set c {}; set d {}
  331.     scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  332.     set a
  333. } 4.6
  334. test scan-2.22 {floating-point scanning} {
  335.     set a {}; set b {}; set c {}; set d {}
  336.     scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  337.     set b
  338. } 99999.7
  339. test scan-2.23 {floating-point scanning} {
  340.     set a {}; set b {}; set c {}; set d {}
  341.     scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  342.     set c
  343. } 87.643
  344. test scan-2.24 {floating-point scanning} {
  345.     set a {}; set b {}; set c {}; set d {}
  346.     scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  347.     set d
  348. } 118
  349. test scan-2.25 {floating-point scanning} {
  350.     set a {}; set b {}; set c {}; set d {}
  351.     scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  352. } 4
  353. test scan-2.26 {floating-point scanning} {
  354.     set a {}; set b {}; set c {}; set d {}
  355.     scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  356.     set a
  357. } 1.2345
  358. test scan-2.27 {floating-point scanning} {
  359.     set a {}; set b {}; set c {}; set d {}
  360.     scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  361.     set b
  362. } 0.697
  363. test scan-2.28 {floating-point scanning} {
  364.     set a {}; set b {}; set c {}; set d {}
  365.     scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  366.     set c
  367. } 124
  368. test scan-2.29 {floating-point scanning} {
  369.     set a {}; set b {}; set c {}; set d {}
  370.     scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  371.     set d
  372. } 5e-05
  373. test scan-2.30 {floating-point scanning} {
  374.     set a {}; set b {}; set c {}; set d {}
  375.     scan "4.6abc" "%f %f %f %f" a b c d
  376. } 1
  377. test scan-2.31 {floating-point scanning} {
  378.     set a {}; set b {}; set c {}; set d {}
  379.     scan "4.6abc" "%f %f %f %f" a b c d
  380.     set a
  381. } 4.6
  382. test scan-2.32 {floating-point scanning} {
  383.     set a {}; set b {}; set c {}; set d {}
  384.     scan "4.6abc" "%f %f %f %f" a b c d
  385.     set b
  386. } {}
  387. test scan-2.33 {floating-point scanning} {
  388.     set a {}; set b {}; set c {}; set d {}
  389.     scan "4.6abc" "%f %f %f %f" a b c d
  390.     set c
  391. } {}
  392. test scan-2.34 {floating-point scanning} {
  393.     set a {}; set b {}; set c {}; set d {}
  394.     scan "4.6abc" "%f %f %f %f" a b c d
  395.     set d
  396. } {}
  397. test scan-2.35 {floating-point scanning} {
  398.     set a {}; set b {}; set c {}; set d {}
  399.     scan "4.6 5.2" "%f %f %f %f" a b c d
  400. } 2
  401. test scan-2.36 {floating-point scanning} {
  402.     set a {}; set b {}; set c {}; set d {}
  403.     scan "4.6 5.2" "%f %f %f %f" a b c d
  404.     set a
  405. } 4.6
  406. test scan-2.37 {floating-point scanning} {
  407.     set a {}; set b {}; set c {}; set d {}
  408.     scan "4.6 5.2" "%f %f %f %f" a b c d
  409.     set b
  410. } 5.2
  411. test scan-2.38 {floating-point scanning} {
  412.     set a {}; set b {}; set c {}; set d {}
  413.     scan "4.6 5.2" "%f %f %f %f" a b c d
  414.     set c
  415. } {}
  416. test scan-2.39 {floating-point scanning} {
  417.     set a {}; set b {}; set c {}; set d {}
  418.     scan "4.6 5.2" "%f %f %f %f" a b c d
  419.     set d
  420. } {}
  421.  
  422. test scan-3.1 {string and character scanning} {
  423.     set a {}; set b {}; set c {}; set d {}
  424.     scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  425. } 4
  426. test scan-3.2 {string and character scanning} {
  427.     set a {}; set b {}; set c {}; set d {}
  428.     scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  429.     set a
  430. } abc
  431. test scan-3.3 {string and character scanning} {
  432.     set a {}; set b {}; set c {}; set d {}
  433.     scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  434.     set b
  435. } def
  436. test scan-3.4 {string and character scanning} {
  437.     set a {}; set b {}; set c {}; set d {}
  438.     scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  439.     set c
  440. } ghijk
  441. test scan-3.5 {string and character scanning} {
  442.     set a {}; set b {}; set c {}; set d {}
  443.     scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  444.     set d
  445. } dum
  446. test scan-3.6 {string and character scanning} {
  447.     set a {}; set b {}; set c {}; set d {}
  448.     scan "a       bcdef" "%c%c%1s %s" a b c d
  449. } 4
  450. test scan-3.7 {string and character scanning} {
  451.     set a {}; set b {}; set c {}; set d {}
  452.     scan "a       bcdef" "%c%c%1s %s" a b c d
  453.     set a
  454. } 97
  455. test scan-3.8 {string and character scanning} {
  456.     set a {}; set b {}; set c {}; set d {}
  457.     scan "a       bcdef" "%c%c%1s %s" a b c d
  458.     set b
  459. } 32
  460. test scan-3.9 {string and character scanning} {
  461.     set a {}; set b {}; set c {}; set d {}
  462.     scan "a       bcdef" "%c%c%1s %s" a b c d
  463.     set c
  464. } b
  465. test scan-3.10 {string and character scanning} {
  466.     set a {}; set b {}; set c {}; set d {}
  467.     scan "a       bcdef" "%c%c%1s %s" a b c d
  468.     set d
  469. } cdef
  470. test scan-3.11 {string and character scanning} {
  471.     set a {}; set b {}; set c {}
  472.     scan "123456 test " "%*c%*s %s %s %s" a b c
  473. } 1
  474. test scan-3.12 {string and character scanning} {
  475.     set a {}; set b {}; set c {}
  476.     scan "123456 test " "%*c%*s %s %s %s" a b c
  477.     set a
  478. } test
  479. test scan-3.13 {string and character scanning} {
  480.     set a {}; set b {}; set c {}
  481.     scan "123456 test " "%*c%*s %s %s %s" a b c
  482.     set b
  483. } {}
  484. test scan-3.14 {string and character scanning} {
  485.     set a {}; set b {}; set c {}
  486.     scan "123456 test " "%*c%*s %s %s %s" a b c
  487.     set c
  488. } {}
  489. test scan-3.15 {string and character scanning} {
  490.     set a {}; set b {}; set c {}; set d
  491.     scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  492. } 4
  493. test scan-3.16 {string and character scanning} {
  494.     set a {}; set b {}; set c {}; set d
  495.     scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  496.     set a
  497. } abab
  498. test scan-3.17 {string and character scanning} {
  499.     set a {}; set b {}; set c {}; set d
  500.     scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  501.     set b
  502. } cd
  503. test scan-3.18 {string and character scanning} {
  504.     set a {}; set b {}; set c {}; set d
  505.     scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  506.     set c
  507. } {01234  }
  508. test scan-3.19 {string and character scanning} {
  509.     set a {}; set b {}; set c {}; set d
  510.     scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  511.     set d
  512. } {f 12345}
  513. test scan-3.20 {string and character scanning} {
  514.     set a {}; set b {}; set c {}
  515.     scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  516. } 3
  517. test scan-3.21 {string and character scanning} {
  518.     set a {}; set b {}; set c {}
  519.     scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  520.     set a
  521. } aabc
  522. test scan-3.22 {string and character scanning} {
  523.     set a {}; set b {}; set c {}
  524.     scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  525.     set b
  526. } bcdefg
  527. test scan-3.23 {string and character scanning} {
  528.     set a {}; set b {}; set c {}
  529.     scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  530.     set c
  531. } 43
  532.  
  533. test scan-4.1 {error conditions} {
  534.     catch {scan a}
  535. } 1
  536. test scan-4.2 {error conditions} {
  537.     catch {scan a} msg
  538.     set msg
  539. } {wrong # args: should be "scan string format ?varName varName ...?"}
  540. test scan-4.3 {error conditions} {
  541.     catch {scan "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21}
  542. } 1
  543. test scan-4.4 {error conditions} {
  544.     catch {scan "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21} msg
  545.     set msg
  546. } {too many fields to scan}
  547. test scan-4.5 {error conditions} {
  548.     catch {scan a %z}
  549. } 1
  550. test scan-4.6 {error conditions} {
  551.     catch {scan a %z} msg
  552.     set msg
  553. } {bad scan conversion character "z"}
  554. test scan-4.7 {error conditions} {
  555.     catch {scan a "%d %d" a}
  556. } 1
  557. test scan-4.8 {error conditions} {
  558.     catch {scan a "%d %d" a} msg
  559.     set msg
  560. } {different numbers of variable names and field specifiers}
  561. test scan-4.9 {error conditions} {
  562.     catch {scan a "%d %d" a b c}
  563. } 1
  564. test scan-4.10 {error conditions} {
  565.     catch {scan a "%d %d" a b c} msg
  566.     set msg
  567. } {different numbers of variable names and field specifiers}
  568. test scan-4.11 {error conditions} {
  569.     set a {}; set b {}; set c {}; set d {}
  570.     expr {[scan "  a" " a %d %d %d %d" a b c d] <= 0}
  571. } 1
  572. test scan-4.12 {error conditions} {
  573.     set a {}; set b {}; set c {}; set d {}
  574.     scan "  a" " a %d %d %d %d" a b c d
  575.     set a
  576. } {}
  577. test scan-4.13 {error conditions} {
  578.     set a {}; set b {}; set c {}; set d {}
  579.     scan "  a" " a %d %d %d %d" a b c d
  580.     set b
  581. } {}
  582. test scan-4.14 {error conditions} {
  583.     set a {}; set b {}; set c {}; set d {}
  584.     scan "  a" " a %d %d %d %d" a b c d
  585.     set c
  586. } {}
  587. test scan-4.15 {error conditions} {
  588.     set a {}; set b {}; set c {}; set d {}
  589.     scan "  a" " a %d %d %d %d" a b c d
  590.     set d
  591. } {}
  592. test scan-4.16 {error conditions} {
  593.     set a {}; set b {}; set c {}; set d {}
  594.     scan "1 2" "%d %d %d %d" a b c d
  595. } 2
  596. test scan-4.17 {error conditions} {
  597.     set a {}; set b {}; set c {}; set d {}
  598.     scan "1 2" "%d %d %d %d" a b c d
  599.     set a
  600. } 1
  601. test scan-4.18 {error conditions} {
  602.     set a {}; set b {}; set c {}; set d {}
  603.     scan "1 2" "%d %d %d %d" a b c d
  604.     set b
  605. } 2
  606. test scan-4.19 {error conditions} {
  607.     set a {}; set b {}; set c {}; set d {}
  608.     scan "1 2" "%d %d %d %d" a b c d
  609.     set c
  610. } {}
  611. test scan-4.20 {error conditions} {
  612.     set a {}; set b {}; set c {}; set d {}
  613.     scan "1 2" "%d %d %d %d" a b c d
  614.     set d
  615. } {}
  616. test scan-4.21 {error conditions} {
  617.     catch {unset a}
  618.     set a(0) 44
  619.     list [catch {scan 44 %d a} msg] $msg
  620. } {1 {couldn't set variable "a"}}
  621. test scan-4.22 {error conditions} {
  622.     catch {unset a}
  623.     set a(0) 44
  624.     list [catch {scan 44 %c a} msg] $msg
  625. } {1 {couldn't set variable "a"}}
  626. test scan-4.23 {error conditions} {
  627.     catch {unset a}
  628.     set a(0) 44
  629.     list [catch {scan 44 %s a} msg] $msg
  630. } {1 {couldn't set variable "a"}}
  631. test scan-4.24 {error conditions} {
  632.     catch {unset a}
  633.     set a(0) 44
  634.     list [catch {scan 44 %f a} msg] $msg
  635. } {1 {couldn't set variable "a"}}
  636. test scan-4.25 {error conditions} {
  637.     catch {unset a}
  638.     set a(0) 44
  639.     list [catch {scan 44 %f a} msg] $msg
  640. } {1 {couldn't set variable "a"}}
  641. catch {unset a}
  642. test scan-4.26 {error conditions} {
  643.     list [catch {scan 44 %2c a} msg] $msg
  644. } {1 {field width may not be specified in %c conversion}}
  645.  
  646. test scan-5.1 {lots of arguments} {
  647.     scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
  648. } 20
  649. test scan-5.2 {lots of arguments} {
  650.     scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
  651.     set a20
  652. } 200
  653.